package com.lizhi.yun.core.organ.controller;

import com.lizhi.common.yun.entity.ListResponseResult;
import com.lizhi.common.yun.enums.OrganStateEnum;
import com.lizhi.common.yun.enums.UserStateEnum;
import com.lizhi.yun.db.pojo.UppOrganPOJO;
import com.lizhi.utils.tools.EnumUtil;
import com.lizhi.yun.core.organ.handler.UppOrganHandle;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.Map;


@RestController
@RequestMapping(path = "/api/upp/organ")
public class UppOrganController {

    @Resource
    private UppOrganHandle uppOrganHandle;

    @PostMapping(path = "/doMain")
    public ListResponseResult doMain(@RequestParam Map<String, Object> map) {
        return uppOrganHandle.doMain(map);
    }

    @PostMapping(value = "/doAdd")
    public ListResponseResult doAdd(@RequestBody UppOrganPOJO uppOrganPOJO) {
        return uppOrganHandle.insert(uppOrganPOJO);
    }

    @PostMapping(value = "/doUpdate")
    public ListResponseResult doUpdate(@RequestBody UppOrganPOJO uppOrganPOJO) {
        return uppOrganHandle.update(uppOrganPOJO);
    }

    @DeleteMapping(path = "/doDelete")
    public ListResponseResult doDelete(String organId) {
        return uppOrganHandle.delete(organId);
    }

    @PostMapping(path = "/isNotexists")
    public boolean isNotexistsUppOrgan(String organId) {
        return uppOrganHandle.isNotexists(organId);
    }

    @PostMapping(path = "/selectById")
    public UppOrganPOJO findUppOrganById(String organId) {
        return uppOrganHandle.findById(organId);
    }

    @GetMapping(path = "/selectUserStateList")
    public Map<String, String> findUppStateList() {
         return EnumUtil.getEnumClassList(UserStateEnum.class);
    }

    @GetMapping(path = "/selectOragnStateList")
    public Map<String, String> findUppOragnStateList() {
         return EnumUtil.getEnumClassList(OrganStateEnum.class);
    }

	@PostMapping(path = "/selectOrgan")
	public String selectOrgan(String organId, String organNm) {
		return uppOrganHandle.selectOrgan(organId, organNm);
	}

	@PostMapping(path = "/selectOrganNmById")
	public String findOrganNmById(String organId){
        return uppOrganHandle.findOrganNmById(organId);
    }
}